<?php


namespace App\Excel\Export;


use Maatwebsite\Excel\Concerns\Exportable;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithTitle;

class HsCode implements WithHeadings, WithTitle
{
    use Exportable;
    /**
     * @var string
     */
    private $code;

    /**
     * HsCode constructor.
     * @param string $code
     */
    public function __construct(string $code)
    {
        $this->code = $code;
    }

    /**
     * @return array
     */
    public function headings(): array
    {
        $hsCode = app(\App\Repositories\HsCode::class);
        $headers = $hsCode->templateHeaders(
            $hsCode->find($this->code)
        );
        return $headers;
    }

    /**
     * @return string
     */
    public function title(): string
    {
        return $this->code;
    }
}
